using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using GonzalesCore.CoreElements;
using GonzalesCore.CoreManagers;
using Kypris2.CoreElements;
using Kypris2.Utils;
using Jamila2.Tools;

public partial class GonzalesUtilities : System.Web.UI.Page
{
    protected PrivateLoginSession CurrentPrivateSession = null;
    protected LogManager CurLogManager = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        this.SessionCheck();
        this.PageComponentSetup();
        this.SwitchLanguage();

        // user right
        this.hpl_UtilitiesEmployeeMaster.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.hpl_UtilitiesProjectMaster.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.hpl_UtilitiesExchangeRate.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin);
        this.hpl_UtilitiesProfitCenterMaster.Enabled = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager);
        this.hpl_UtilitiesCOAClaimableExpense.Enabled = this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager;

        // style
        this.hpl_UtilitiesEmployeeMaster.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.hpl_UtilitiesProjectMaster.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.hpl_UtilitiesExchangeRate.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin) ? "GridViewLink" : "GridViewLinkDisabled";
        this.hpl_UtilitiesProfitCenterMaster.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager) ? "GridViewLink" : "GridViewLinkDisabled";
        this.hpl_UtilitiesCOAClaimableExpense.CssClass = (this.CurrentPrivateSession.CurrentLoggedOnUser.IsPowerAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinanceAdmin || this.CurrentPrivateSession.CurrentLoggedOnUser.IsFinancialManager) ? "GridViewLink" : "GridViewLinkDisabled";
    }

    #region Customized Methods

    #region SessionCheck
    public void SessionCheck()
    {
        if (Session[GonzalesCommonNamingConvention.CurrentPrivateSession] != null)
        {
            this.CurrentPrivateSession = (PrivateLoginSession)Session[GonzalesCommonNamingConvention.CurrentPrivateSession];
            this.CurLogManager = new LogManager(this.CurrentPrivateSession);    // activate Log Manager

            if (!this.CurrentPrivateSession.CurrentLoggedOnUser.IsAdmin)
            {
                Response.Redirect(GonzalesErrorPageRedirect.SessionError);
            }
        }
        else
        {
            Response.Redirect(GonzalesErrorPageRedirect.SessionError);
        }

    }
    #endregion

    #region PageComponentSetup
    protected void PageComponentSetup()
    {

    }
    #endregion

    #region SwitchLanguage
    protected void SwitchLanguage()
    {
        try
        {
            using (MultiLingualFactory CurLanguageFactory = MultiLingualEngine.GetMultiLingualFactory(this, this.CurrentPrivateSession.CurrentLoggedOnUser.PreferedLanguage.InternalID))
            {
                this.lbl_PageTitle.Text = CurLanguageFactory.DisplayValue("PageTitle");
                this.lbl_Information.Text = CurLanguageFactory.DisplayValue("Information");
                this.lbl_Utilities.Text = CurLanguageFactory.DisplayValue("Utilities");
               
                this.hpl_UtilitiesEmployeeMaster.Text = CurLanguageFactory.DisplayValue("EmployeeMaster");
                this.hpl_UtilitiesProjectMaster.Text = CurLanguageFactory.DisplayValue("ProjectMaster");
                this.hpl_UtilitiesExchangeRate.Text = CurLanguageFactory.DisplayValue("ExchangeRate");
                this.hpl_UtilitiesProfitCenterMaster.Text = CurLanguageFactory.DisplayValue("ProfitCenterMaster");
                this.hpl_UtilitiesCOAClaimableExpense.Text = CurLanguageFactory.DisplayValue("ChartOfAccountClaimableExpense");
                //this.HyperLink_CreditCardReport.Text = CurLanguageFactory.DisplayValue("CreditCardReport");
                //this.HyperLink_EntityBasedSetup.Text = CurLanguageFactory.DisplayValue("EntityBasedSetup");
                //this.HyperLink_ErrorLog.Text = CurLanguageFactory.DisplayValue("ErrorLog");
                //this.HyperLink_ExceptionalApprovingSetting.Text = CurLanguageFactory.DisplayValue("ExceptionalApprovingSetting");
                //this.HyperLink_ExpenseDetailLimit.Text = CurLanguageFactory.DisplayValue("ExpenseDetailLimit");
                //this.HyperLink_FinanceAdminSetting.Text = CurLanguageFactory.DisplayValue("FinanceAdminSetting");
                //this.HyperLink_FinanceApprover.Text = CurLanguageFactory.DisplayValue("FinanceApprover");
                //this.HyperLink_GeneralActionLog.Text = CurLanguageFactory.DisplayValue("GeneralActionLog");
                //this.HyperLink_Guide1.Text = CurLanguageFactory.DisplayValue("Guide1");
                //this.HyperLink_LanguageTranslation.Text = CurLanguageFactory.DisplayValue("LanguageTranslation");
                //this.HyperLink_ReportActiveExpenseDetail.Text = CurLanguageFactory.DisplayValue("ReportActiveExpenseDetail");
                //this.HyperLink_ReportGeneralClaimant.Text = CurLanguageFactory.DisplayValue("ReportGeneralClaimant");
                //this.HyperLink_ReportGeneralClaims.Text = CurLanguageFactory.DisplayValue("ReportGeneralClaims");
                //this.HyperLink_TestEmail.Text = CurLanguageFactory.DisplayValue("TestEmail");
                //this.HyperLink_ChangeStatus.Text = CurLanguageFactory.DisplayValue("ChangeStatus");
                //this.HyperLink_ApproverReplacement.Text = CurLanguageFactory.DisplayValue("ApproverReplacment");
            }
        }
        catch (Exception ex)
        {
            this.CurLogManager.LogError("[GonzalesUtilities.SwitchLanguage.EX] : " + ex.Message, this.CurrentPrivateSession.CurrentLoggedOnUser, LogInterface.User);
        }

    }
    #endregion

    #endregion
}